package com.thf.controller.product;

import com.alibaba.fastjson.JSON;
import com.thf.util.Upload;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

@Controller
public class ProductWangeditorUploadController {
    @RequestMapping("/wangEditor/upload")
    @ResponseBody
    protected String imgUpload(@RequestParam("file") MultipartFile file , HttpServletRequest req ) throws ServletException, IOException {
        String path = Upload.file(file,req);
        //       反馈给前端--返回值
        //System.out.println(resJson);
        return JSON.toJSONString(path) ;
    }
}
